<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var a={
        test:function (func) {
           a.test=func;
           a.test();
        }
    }

    a.test(function (b=null) {
        if(b){
            a.test=b;
        }else {
            console.log(this);
            console.log(123)
        }
    });
    a.test(function () {
        console.log(this);
        console.log(222)
    });
    a.test();
</script>
</body>
</html>